/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.qlks.controller.baocaothang;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.rowset.WebRowSet;
import uit.ejb.bo.baocaothang.BaoCaoThangBORemote;
import uit.ejb.bo.baocaothang.BaoCaoThangBORemoteHome;
import uit.ejb.dto.BaoCaoThangDTO;

/**
 *
 * @author Restart
 */
public class BaoCaoThangController {

    private static Context ctx;
    private static BaoCaoThangBORemoteHome phome;
    private static BaoCaoThangBORemote bct;

    public BaoCaoThangController(){

    }

    public static void Register(){
        try{
            ctx = new InitialContext();
            Object obj = ctx.lookup("ejb/BaoCaoThangBO");
            phome = (BaoCaoThangBORemoteHome) PortableRemoteObject.narrow(obj, BaoCaoThangBORemoteHome.class);
            bct=phome.create();
        }
        catch(Exception e){
        }
    }

    public static boolean baoCaoThang_Insert(BaoCaoThangDTO bcthang){
        try{
            Register();
            bct.baoCaoThang_Insert(bcthang);
            return true;
        }catch(Exception e){
            return false;
        }
    }

    public static boolean baoCaoThang_Update(BaoCaoThangDTO bcthang){
        try{
            Register();
            bct.baoCaoThang_Update(bcthang);
            return true;
        }catch(Exception e){
            return false;
        }
    }
    public static boolean baoCaoThang_Delete(String id) {
        try{
            Register();
            return bct.baoCaoThang_Delete(id);
        }catch(Exception e){
            return false;
        }
    }

    public static WebRowSet baoCaoThang_GetById(String id) {
        try{
            Register();
            return bct.baoCaoThang_GetById(id);
        }catch(Exception e){
            return null;
        }
    }

    public static WebRowSet baoCaoThang_GetByTop(String top, String where, String order) {
        try{
            Register();
            return bct.baoCaoThang_GetByTop(top, where, order);
        }catch(Exception e){
            return null;
        }
    }
}
